{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=1468
  Verdict: Accepted
}
uses SysUtils, Math;
 
const
	month:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);
 
var
	d,m,y,kk,i:longint;
	s:string;
	ans:int64;
 
function bis(y:longint):boolean;
begin
result:=(y mod 400=0) or ((y mod 4=0) and (y mod 100<>0));
end;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(S);
d:=strtoint(s[1]+s[2]);
m:=strtoint(s[3]+s[4]);
y:=strtoint(copy(s,5,4));
kk:=y-1;
ans:=0;
for i:=1 to kk do begin
	inc(ans,365);
	if bis(i) then inc(ans);
end;
kk:=m-1;
if (m>2) and bis(y) then inc(ans);
for i:=1 to kk do inc(ans,month[i]);
inc(ans,d);
write(ans);
end.